<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改商品</title>
<link rel="stylesheet" href="/wk1un2/Backstage/lib/layui/css/layui.css" />
</head>
<body>
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">商品ID:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="id" name="id" class="layui-input"
					readonly="true">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">商品名称:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="name" name="name" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">商品材质:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="materal" name="materal" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">商品售价:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="salePrice" name="salePrice" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">市场价:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="markePrice" name="markePrice" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">品牌:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="brand" name="brand" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">是否组装:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="zuZhuang" name="zuZhuang" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">是否定制:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="dingZhi" name="dingZhi" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">型号:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="xingHao" name="xingHao" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">颜色:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="color" name="color" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">设计元素:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="yuanSu" name="yuanSu" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">设计风格:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="fengGe" name="fengGe" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">产品款式:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="kuanShi" name="kuanShi" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">所属产品分类:</label>
			<div class="layui-input-inline"  style="width: 350px;">
				<select name="productTypeId"  id="productTypeId" lay-search="">
					<option value="">点击选取分类名字</option>
					<c:forEach items="${type }" var="t">
					<option value="${t.id }">${t.name }</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">产品图片:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="picUrl" name="picUrl" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">是否显示主页:</label>
			<div class="layui-input-inline" style="width: 350px;">
				<input type="text" id="homeFlag" name="homeFlag" required=""
					autocomplete="off" class="layui-input" >
			</div>
		</div>
		<div class="layui-btn-container" style="text-align: center;">
			<button class="layui-btn" lay-filter="productEditBtu" lay-submit="">
				修改</button>
		</div>
	</form>
	<script type="text/javascript"
		src="/wk1un2/Backstage/lib/layui/layui.js"></script>
	<script>
		//加载了layui的form模块
		layui.use('form', function() {
			var form = layui.form;
			var $ = layui.jquery; //引入jquery
			//监听提交
			form.on('submit(productEditBtu)', function(data) {
				var d = data.field; //表单中的数据，定义一个对象来接收
				d.method = "update"; // 执行的方法
				//通过ajax向数据库提交数据了
				console.log(d); //提交之前的一个数据验证、通过打印的方式先手动的去判断一下这个数据
				var url = '/wk1un2/HouProductServlet';//请求的接口
				//确保数据没有问题就进行ajax提交了
				$.post(url, d, function(data) {
					if (data.count > 0) {
						console.log('修改成功');
						var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
						parent.layer.close(index); //关闭窗口
					}
				}, "json");
				return false;
			});
		});
	</script>
</body>
</html>